package com.rwlai.dianshang.domain;

import com.qunchuang.bos.Bostype;
import com.qunchuang.bos.Entry;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

/**
 * Created by liutim on 2017/11/23.
 */
@Entity
@Bostype("A13")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class OrderItem extends Entry {


    //演示父子关系的另一侧
    //两行照抄
    @ManyToOne(fetch = FetchType.LAZY)
    @Access(AccessType.PROPERTY)
    //照抄，然后把返回类型改为Order并做强制转换
    public Order getParent() {
        return (Order)super.getInnerParent();
    }

    public Product getProduct() {
        return product;
    }

    //演示另一种引用关系
    @ManyToOne(fetch = FetchType.LAZY)
    private Product product;

    private int count;


    @Override
    public String toString() {
        return this.getId()+":"+this.product.getId()+":"+this.count;
    }
}
